package com.packet.cheng;

import java.util.concurrent.*;

public class Test {
     public  static  int  removeDuplicates(int[] nums){

         if (nums == null && nums.length ==0){
             return 0;
         }
         //定义一个右指针
         int j = 0;
         for (int i = 0;i<nums.length;i++){
             if (nums[j] != nums[i]){
                 j++;
                 nums[j] = nums[i];
             }
         }
         for (int i =0;i<nums.length;i++){
             System.out.println(nums[i]);
         }
         return ++j;
     }

    public static void main(String[] args) throws ExecutionException, InterruptedException {
//        int[] nums = {0,9,2,5,4,4,5,5,6};
//        System.out.println("哈哈哈"+removeDuplicates(nums));
        ExecutorService service = new ThreadPoolExecutor(2,3,1000, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<>(1000),new ThreadPoolExecutor.AbortPolicy());
        Future<?> future1 = service.submit(() -> {
            Future<?> future2 = service.submit(() -> {
                System.out.println("future2内部线程开始执行...");
            });
            try {
                future2.get();
                System.out.println("future2内部线程执行完毕");
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            } catch (ExecutionException e) {
                throw new RuntimeException(e);
            }
        });
        future1.get();
        System.out.println("future1获取到结果，开始往下执行");
    }
}